<?php $this->load->module('mobile/index/header', $common);?>
<div class="content">
    <div id="list">

                <div class="list-item fn-clear">
                    <div class="info">
                        <h5><?php echo $info['order_title'];?></h5>
                        <div class="i-note">
                            <p class="price">
                                <?php if (!empty($info['order_account'])) :?>
                                    ¥<?php echo $info['order_account'];?>
                                <?php endif; ?>
                            </p>
                            <p class="c_mt">订单编号：<?php echo $info['order_sn'];?></p>
                            <p class="c_mt">订单状态：<?php echo $info['order_status_name'];?><?php if($info['order_status'] == 4):?> , 未入住<?php endif;?></p>
                            <p class="c_mt">人数：<?php echo $info['order_num'];?></p>


                            <p class="c_mt js-show-goods">菜品：点击查看</p>
                            <div class="js-goods-wrap" style="display: none">
                            <?php if($goods_list):?>
                                <?php foreach ($goods_list as $key=>$item):?>
                                    <?php if($item['number']):?>
                                       <p class="c_mt"> ★ <?php echo $item['name'];?>：<?php echo $item['number'];?>份 <?php echo $item['total'];?>元</p>
                                    <?php endif;?>
                                <?php endforeach;?>
                            <?php endif;?>
                            </div>

                            <p class="c_mt">订单定金：<?php echo $info['earnest_account'];?>元</p>
                            <p class="c_mt">已支付定金：<?php echo $info['earnest_paid_account'];?>元</p>
                            <p class="c_mt">未支付：<?php echo $info['order_account']-$info['paid_account'];?>元</p>
                            <p class="c_mt">支付状态：<?php echo $info['pay_status_name'];?></p>

                            <p class="c_mt">入住时间：<?php echo $info['start_date'];?></p>
                            <p class="c_mt">离店时间：<?php echo $info['end_date'];?></p>
                            <p class="c_mt">下单时间：<?php echo $info['add_time'];?></p>


                        </div>
                        

                        </div>
                    </div>

                    <div class="info">
                        <div class="i-note">
                           <!-- <div class="i-note-title">消费菜品</div>-->

                    </div>

                </div>

    </div>
    <?php if($user_id){?>
    <div class="col_div">
        <?php if($pay['pay_identify']):?>
        <a data-href="<?php echo $info['pay_url'];?>" class="btn btn-orange js-btn-submit" title="<?php echo $pay['pay_title'];?>"><?php echo $pay['pay_title'];?></a>
        <?php endif ;?>
        <?php if($info['cancel_identify']=='1'):?>
            <a href="javascript:void(0)" class="btn btn-grey btn_cancel" title="立即取消">取消</a>
        <?php endif ;?>
    </div>
    <?php }?>


</div>
<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">
    function alert_popup(text){
        $.dialog({
            style:'tip',
            width:200,
            closeTime:1000,
            content: '<p style="text-align: center">'+text+'</p>'
        }).open();
    }

    var order_id = <?php  echo $info['order_id'];?>  ;
    $(function(){

        $('.js-show-goods').click(function () {
            var text = $(this).text();

            if(text == '菜品：点击查看'){
                $(this).text('菜品：收起');
            }else {
                $(this).text('菜品：点击查看');
            }
            $('.js-goods-wrap').toggle();
        })

        $('.btn_cancel').click(function(){
            if(confirm('确定要取消订单吗？')){
                $.post('<?php  echo $info['cancel_url'];?>',{
                    order_id:order_id
                },function(data){
                    alert_popup(data.info);
                    if (data.status == '1') {

                        setTimeout(function(){
                            window.location.reload();
                        }, 1000);
                    }
                },'json')
            }

        })


        $('.js-btn-submit').click(function () {

            var url = $(this).data('href');
            $.post('<?php  echo $info['check_pay_url'];?>',{
                id:order_id
            },function(data){

                if (data.status == 0) {
                    alert_popup(data.info);
                    return false;
                }

                if (data.status == 1) {

                    window.location.href = url;
                }


            },'json')
        })
    });
</script>